package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(LoginException.class)
    public Result<?> handleBusinessException(LoginException e){
        e.printStackTrace();
        return  Result.fail(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result<Void> error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
}